package com.axt.dbaudit.bean;

import java.util.List;

import com.axt.dbaudit.base.MsgFuncExt;
import com.axt.dbaudit.model.Log;
import com.axt.soa.bean.BaseFuncBean;
import com.axt.soa.msg.types.MsgErrorCode;
import com.axt.soa.msg.types.MsgParam;

public class LogBean extends BaseFuncBean {
	private String errInfo;
	private int errCode;
	
	public String getErrInfo() {
		return errInfo;
	}
	public void setErrInfo(String errInfo) {
		this.errInfo = errInfo;
	}
	public int getErrCode() {
		return errCode;
	}
	public void setErrCode(int errCode) {
		this.errCode = errCode;
	}
	/**
	 * 获取管理平台日志 信息
	 * @return
	 */
	public List<Log> queryManagerLogs() {
		List<Log> logs=fetch(MsgFuncExt.FUNC_QUERY_LOG,
				"com.axt.dbaudit.model.Log", "Log", CONN_T_TCP);
		if(logs == null){
			errCode = reply.getParam(MsgParam.PARA_ERR_CODE).toInteger();
			errInfo = MsgErrorCode.getErrInfo(errCode);
			return null;
		}

		return logs;
		
		//List<Log> oLogs = null;
		//int nRetVal = execute(MsgOperateConsts.FUNC_LOG_QUERY, CONN_T_TCP);
		//if (-1 != nRetVal) {
        //   DBRecord clRecord =  reply.getRecord(MsgParam.MSG_TG_SERVER_LOG);
        //   oLogs = new ArrayList<Log>();

		//	for (int i = 0; i < clRecord.getRowCount(); i++) {
		//		Log clNode = new Log();
		//		clNode.setDBType(clRecord.getValue(i, 0).getInteger());
		//		clNode.setSzTime(clRecord.getValue(i, 1).getString());
		//		clNode.setSzevent(clRecord.getValue(i, 2).getString());
		//		clNode.setSztext(clRecord.getValue(i, 3).getString());
		//		clNode.setAUserName(clRecord.getValue(i, 4).getString());
		//		oLogs.add(clNode);
		//	}
		//}
		//return oLogs;
	}
	/**
	 * 获取节点的日志信息
	 * @param aServerId
	 * @return
	 */
	public List<Log> queryNodeLogs(String serverId) {
		request.addParam(MsgParam.PARA_SVR_PATH, serverId);
		List<Log> logs= fetch(MsgFuncExt.FUNC_QUERY_LOG,
				"com.axt.dbaudit.model.Log", "Log", CONN_T_TCP);
		if(logs == null){
			errCode = reply.getParam(MsgParam.PARA_ERR_CODE).toInteger();
			errInfo = MsgErrorCode.getErrInfo(errCode);
			return null;
		}
		return logs;
		//List<Log> oLogs = null;
		//int nRetVal = execute(MsgOperateConsts.FUNC_LOG_QUERY, CONN_T_TCP);
		//if (-1 != nRetVal) {
          // DBRecord clRecord =  reply.getRecord(MsgParam.MSG_TG_AU_SYS_LOG);
          // oLogs = new ArrayList<Log>();

			//for (int i = 0; i < clRecord.getRowCount(); i++) {
				//Log clNode = new Log();
				//clNode.setDBType(clRecord.getValue(i, 0).getInteger());
				//clNode.setSzTime(clRecord.getValue(i, 1).getString());
				//clNode.setSzevent(clRecord.getValue(i, 2).getString());
				//clNode.setSztext(clRecord.getValue(i, 3).getString());
				//clNode.setAUserName(clRecord.getValue(i, 4).getString());
				//oLogs.add(clNode);
			}
}
